package com.freelance.vn.apps.puzzle.utils;

import com.freelance.vn.apps.puzzle.R;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.Config;

public class Pictures {
	public Bitmap img; // picture image
	private int coordX = 0; // the x coordinate at the canvas
	private int coordY = 0; // the y coordinate at the canvas
	private int bottom;
	private int right;
	
	private int id; // gives every picture a unique id
	
	public Pictures(Bitmap bm,int id){
		img=bm.copy(Config.RGB_565, true);
		this.id=id;		
	}
	
	public Pictures( Context context, int drawable,int imageID ) {
		Bitmap originBitmap = BitmapFactory.decodeResource(context.getResources(),imageID);
		ImageCropper mCropper= new ImageCropper(originBitmap);
		switch ( drawable ) {
			case 0:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_00);
				img=mCropper.getBitmap(0,0);
				id = drawable;
				break;
			case 1:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_01);
				img=mCropper.getBitmap(1,0);
				id = drawable;
				break;
			case 2:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_02);
				img=mCropper.getBitmap(2,0);
				id = drawable;
				break;
			case 3:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_03);
				img=mCropper.getBitmap(3, 0);
				id = drawable;
				break;
			case 4:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_10);
				img=mCropper.getBitmap(0,1);
				id = drawable;
				break;
			case 5:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_11);
				img=mCropper.getBitmap(1,1);
				id = drawable;
				break;
			case 6:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_12);
				img=mCropper.getBitmap(2,1);
				id = drawable;
				break;
			case 7:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_13);
				img=mCropper.getBitmap(3, 1);
				id = drawable;
				break;
			case 8:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_20);
				img=mCropper.getBitmap(0, 2);
				id = drawable;
				break;
			case 9:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_21);
				img=mCropper.getBitmap(1, 2);
				id = drawable;
				break;
			case 10:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_22);
				img=mCropper.getBitmap(2, 2);
				id = drawable;
				break;
			case 11:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_23);
				img=mCropper.getBitmap(3, 2);
				id = drawable;
				break;
			case 12:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_30);
				img=mCropper.getBitmap(0, 3);
				id = drawable;
				break;
			case 13:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_31);
				img=mCropper.getBitmap(1, 3);
				id = drawable;
				break;
			case 14:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_32);
				img=mCropper.getBitmap(2, 3);
				id = drawable;
				break;
			case 15:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_33);
				img=mCropper.getBitmap(3, 3);
				id = drawable;
				break;
			case 16:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_40);
				img=mCropper.getBitmap(0, 4);
				id = drawable;
				break;
			case 17:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_41);
				img=mCropper.getBitmap(1, 4);
				id = drawable;
				break;
			case 18:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_42);
				img=mCropper.getBitmap(2, 4);
				id = drawable;
				break;
			case 19:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_43);
				img=mCropper.getBitmap(3, 4);
				id = drawable;
				break;
			case 20:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_50);
				img=mCropper.getBitmap(0, 5);
				id = drawable;
				break;
			case 21:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_51);
				img=mCropper.getBitmap(1, 5);
				id = drawable;
				break;
			case 22:
//				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.ice_age_52);
				img=mCropper.getBitmap(2, 5);
				id = drawable;
				break;
			case 23:
				img = BitmapFactory.decodeResource(context.getResources(), R.drawable.square);
				id = drawable;
				break;
		}
	}
	
	public int getID() {
		return id;
	}
	
	void setX( int newValue ) {
        coordX = newValue;
    }
	public int getX() {
		return coordX;
	}
	
	void setY( int newValue ) {
        coordY = newValue;
	}
	public int getY() {
		return coordY;
	}
	
	void setRight( int w ) {
		right = w;
	}
	int getRight() {
		return right;
	}
	
	void setBottom( int h ) {
		bottom = h;
	}
	int getBottom() {
		return bottom;
	}
	
	public Bitmap getBitmap() {
		return img;
	}
}
